package cn.wxManage.goodsManage.controller;

import cn.common.common.model.ServerResponse;
import cn.wxManage.goodsManage.model.GoodsOrder;
import cn.wxManage.goodsManage.service.IGoodsOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by Zhang on 2019/1/24.
 */
@RestController
@RequestMapping("/goods")
@Api(value="订单相关方法",description = "订单相关方法")
public class GoodsOrderController {
    @Autowired
    IGoodsOrderService iGoodsOrderService;

    @ApiOperation(value="直接在商品界面针对某一款式下订单", notes="直接在商品界面针对某一款式下订单",produces = "application/json")
    @PostMapping(value = "/addOrderInGoodsView")
    public ServerResponse<?> addOrderInGoodsView(@RequestBody GoodsOrder goodsOrder){
        return iGoodsOrderService.addOrderInGoodsView(goodsOrder);
    }

    @ApiOperation(value="在购物车界面下单", notes="在购物车界面下单",produces = "application/json")
    @PostMapping(value = "/addOrderInCartView")
    public ServerResponse<?> addOrderInCartView(@RequestParam("ids") List<Integer> ids,
                                                @RequestParam("goodsOrder") GoodsOrder goodsOrder){
        return iGoodsOrderService.addOrderInCartView(ids,goodsOrder);
    }

    @ApiOperation(value="获取各个状态下的订单列表,按照创建时间排序",
            notes="获取各个状态下的订单列表,按照创建时间排序",produces = "application/json")
    @GetMapping(value = "/getOrderByStatus")
    public ServerResponse<?> getOrderByStatus(@RequestParam("status") String status){
        return iGoodsOrderService.getOrderByStatus(status);
    }

    @ApiOperation(value="获取指定订单详情",
            notes="获取指定订单详情",produces = "application/json")
    @GetMapping(value = "/getOrderInfo")
    public ServerResponse<?> getOrderInfo(@RequestParam("id") Integer id){
        return iGoodsOrderService.getOrderInfo(id);
    }
}
